//
//  GoodManagerAddChooseTypeCell.m
//  ReceiptDelivery
//
//  Created by 吕晶 on 2020/9/21.
//  Copyright © 2020 吕晶. All rights reserved.
//

#import "GoodManagerAddChooseTypeCell.h"

@interface GoodManagerAddChooseTypeCell ()

@property (nonatomic, strong) UIView *bgView;
@property (nonatomic, strong) UILabel *titleLab;
@property (nonatomic, strong) UILabel *lineLab;
@property (nonatomic, strong) UITextField *content1Field;
@property (nonatomic, strong) UIButton *btn1;
@property (nonatomic, strong) UITextField *content2Field;
@property (nonatomic, strong) UIButton *btn2;

@end

@implementation GoodManagerAddChooseTypeCell

+ (instancetype)GoodManagerAddChooseTypeCellWithTableView:(UITableView *)tableView {
    static NSString *cellID = @"GoodManagerAddChooseTypeCell";
    GoodManagerAddChooseTypeCell *cell = [tableView dequeueReusableCellWithIdentifier:cellID];
    if (cell == nil) {
        cell = [[GoodManagerAddChooseTypeCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellID];
    }
    return cell;
}

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        self.backgroundColor = Color_backgroundColor;
        self.selectionStyle = UITableViewCellSelectionStyleNone;
        
        self.bgView = [[UIView alloc] initWithFrame:CGRectMake(15, 0, ScreenW - 30, 60)];
        self.bgView.backgroundColor = HexColor(0xffffff);
        [self.contentView addSubview:self.bgView];
        
        self.lineLab = [[UILabel alloc] initWithFrame:CGRectMake(10, self.bgView.nim_height - 1, self.bgView.nim_width - 20, 1)];
        self.lineLab.backgroundColor = Color_backgroundColor;
        [self.bgView addSubview:self.lineLab];
        
        self.titleLab = [[UILabel alloc] initWithFrame:CGRectMake(10, 22.5, 120, 15)];
        self.titleLab.font = [UIFont systemFontOfSize:14];
        self.titleLab.textColor = HexColor(0x2B2C44);
        [self.bgView addSubview:self.titleLab];
        
        self.content2Field = [[UITextField alloc] initWithFrame:CGRectMake(self.bgView.nim_width - 10 - (self.bgView.nim_width - 10 - self.titleLab.nim_right - 10 - 10) * 0.5, 10, (self.bgView.nim_width - 10 - self.titleLab.nim_right - 10 - 10) * 0.5, 40)];
        self.content2Field.font = [UIFont systemFontOfSize:15];
        self.content2Field.textColor = HexColor(0x000000);
        self.content2Field.textAlignment = NSTextAlignmentRight;
        self.content2Field.userInteractionEnabled = NO;
        [self.bgView addSubview:self.content2Field];
        UIImageView *img2View = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 18, 18)];
        img2View.image = [UIImage imageNamed:@"icon_lower_person_info"];
        self.content2Field.placeholder = @"请选择";
        self.content2Field.rightView = img2View;
        self.content2Field.rightViewMode = UITextFieldViewModeAlways;
        
        self.btn2 = [[UIButton alloc] initWithFrame:self.content2Field.frame];
        [self.btn2 addTarget:self action:@selector(btn2Click) forControlEvents:UIControlEventTouchUpInside];
        [self.bgView addSubview:self.btn2];
        
        self.content1Field = [[UITextField alloc] initWithFrame:CGRectMake(self.titleLab.nim_right + 10, 10, (self.bgView.nim_width - 10 - self.titleLab.nim_right - 10 - 10) * 0.5, 40)];
        self.content1Field.font = [UIFont systemFontOfSize:15];
        self.content1Field.textColor = HexColor(0x000000);
        self.content1Field.textAlignment = NSTextAlignmentRight;
        self.content1Field.userInteractionEnabled = NO;
        [self.bgView addSubview:self.content1Field];
        UIImageView *img1View = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 18, 18)];
        img1View.image = [UIImage imageNamed:@"icon_lower_person_info"];
        self.content1Field.placeholder = @"请选择";
        self.content1Field.rightView = img1View;
        self.content1Field.rightViewMode = UITextFieldViewModeAlways;
        
        self.btn1 = [[UIButton alloc] initWithFrame:self.content1Field.frame];
        [self.btn1 addTarget:self action:@selector(btn1Click) forControlEvents:UIControlEventTouchUpInside];
        [self.bgView addSubview:self.btn1];
        
        self.height = self.bgView.nim_bottom;
    }
    return self;
}

- (void)btn1Click {
    if (self.click1Block) {
        self.click1Block();
    }
}

- (void)btn2Click {
    if (self.click2Block) {
        self.click2Block();
    }
}

-(void)setTitleText:(NSString *)titleText {
    _titleText = titleText;
    self.titleLab.text = titleText;
}

-(void)setContent1Text:(NSString *)content1Text {
    _content1Text = content1Text;
    self.content1Field.text = content1Text;
}

-(void)setContent2Text:(NSString *)content2Text {
    _content2Text = content2Text;
    self.content2Field.text = content2Text;
}

-(void)setShowLine:(BOOL)showLine {
    _showLine = showLine;
    self.lineLab.hidden = !showLine;
}

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
